package com.comdo.newup_loan.module.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.comdo.newup_loan.R;
import com.comdo.newup_loan.base.BaseActivity;
import com.comdo.newup_loan.util.StringUtils;
import com.comdo.newup_loan.util.TitleMenuUtil;
import com.umeng.analytics.MobclickAgent;

import butterknife.BindView;

/**
 * Created by liyuan on 2017/11/2.
 */

public class SuggestionActivity extends BaseActivity<SuggestionPresenter> implements SuggestionContract.View{
    @BindView(R.id.ed_title)
    EditText mTitleEditText;
    @BindView(R.id.ed_content)
    EditText mContentEditText;
    @BindView(R.id.ed_email)
    EditText mEmailEditText;
    @BindView(R.id.btn_sumbit)
    Button mSubmitButton;
    @Override
    protected int getContentViewLayoutID() {
        return R.layout.layout_suggestion;
    }

    @Override
    protected void init() {
        super.init();

    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        new TitleMenuUtil(SuggestionActivity.this,"意见反馈",false);
        mSubmitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String title=mTitleEditText.getText().toString();
                String content=mContentEditText.getText().toString();
                String email=mEmailEditText.getText().toString();
                if(StringUtils.isNull(content)){
                    showToast("请输入内容！");
                    return;
                }
                if(StringUtils.isNull(content)){
                    showToast("请输入主题！");
                    return;
                }
                mPresenter.sumbit(title,content,email);
            }
        });

    }

    @Override
    public SuggestionPresenter getmPresenter() {
        return new SuggestionPresenter();
    }

    @Override
    public void presenterSetView() {
        if (mPresenter != null)
            mPresenter.setView(this);
    }
    @Override
    protected boolean translucentStatusBar() {
        return true;
    }

    @Override
    public void getFail(String failMessage) {
        showToast(failMessage);
    }

    @Override
    public void success(String Message) {
        showToast(Message);
        toSuccessActivity();

    }
    private void toSuccessActivity(){
        Intent intent=new Intent(SuggestionActivity.this, SuggestionSuccessActivity.class);
        startActivity(intent);
        this.finish();
    }
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("问题反馈");
        MobclickAgent.onResume(this);
    }
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("问题反馈");
        MobclickAgent.onPause(this);
    }
}
